package com.study.spark.ml.movie.basic

import java.awt.Font

import org.jfree.chart.axis.CategoryLabelPositions
import scalax.chart.module.ChartFactories

/**
  * 电影年限分布柱状图
  *
  * @author: stephen.shen
  * @create: 2019-04-10 9:39
  */
object MovieAgesChart {

  def main(args: Array[String]): Unit = {
    val movieYears:Array[(String, Long)] = MovieData.getMovieYearsCountSorted()
    val ds = new org.jfree.data.category.DefaultCategoryDataset
    for(i <- movieYears){
      ds.addValue(i._2,"year", i._1)
    }

    val chart = ChartFactories.BarChart(ds)
    val font = new Font("Dialog", Font.PLAIN,5);
    chart.peer.getCategoryPlot.getDomainAxis().
      setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    chart.peer.getCategoryPlot.getDomainAxis.setLabelFont(font)
    chart.show()

  }
}
